<%= render :partial => "/tr8n/admin/common/header" %>
<%= render :partial => "tabs", :locals => {:current_tab => "#{image_tag("tr8n/icons/page_white_code.png")} #{@source.title}".html_safe} %>

<table class="admin_table">
    <tr>
        <th>
            Application
        </th>
        <td>
            <%=link_to(@source.application.name, :controller => "/tr8n/admin/applications", :action => "view", :id=>@source.application.id, :mode=>:sources) %>
        </td>
    </tr>

    <tr>
        <th width="160">
            Source Id
        </th>
        <td>
            <%=@source.id %>
        </td>
    </tr>
    <tr>
        <th>
            Source Key
        </th>
        <td>
            <%=@source.source %>
        </td>
    </tr>
    <tr>
        <th>
            Name
        </th>
        <td>
            <%=@source.name %>
        </td>
    </tr>
    <tr>
        <th>
            Description
        </th>
        <td>
            <%=@source.description %>
        </td>
    </tr>
    <tr>
        <th>
            Created At
        </th>
        <td>
            <%=@source.created_at %>
        </td>
    </tr>
    <tr>
        <th>
            Updated At
        </th>
        <td>
            <%=@source.updated_at %>
        </td>
    </tr>
    <tr>
        <th>
            
        </th>
        <td>
        <%= tr8n_actions_tag([ 
            link_to_function("Update", "Tr8n.UI.Lightbox.show('/tr8n/admin/sources/lb_update?id=#{@source.id}', {height:350})"),
            link_to("Recalculate All Metrics", "/tr8n/admin/applications/recalculate_source?source_id=#{@source.id}", :confirm => "Are you sure you want to recalculate all metrics for this source?"),
            link_to("Remove All Keys", "/tr8n/admin/applications/remove_keys_from_source?all=true&id=#{@source.id}", :confirm => "Are you sure you want to remove all keys from this source?")
          ])
        %>
        </td>
    </tr>    
</table>

<%=  tr8n_sections_tag(:modes => [
          ["Source Metrics",    {:mode => :metrics}],
          ["Translation Keys",  {:mode => :translation_keys}],
          ["Translations",      {:mode => :translations}],
        ],
        :params => {
            :id => @source.id
        },
        :title => lambda{ |mode|
          html = []
          html << "#{mode.first} "
          if mode.last[:mode] == :metrics
            if params[:charts] == "true"
              html << "<span style='font-size:12px;'>"
              html << link_to("view as table", params.merge(:charts => false)) 
              html << "</span>"
            else
              html << "<span style='font-size:12px;'>"
              html << link_to("view as charts", params.merge(:charts => true)) 
              html << "</span>"
            end
          end
          html.join("").html_safe
        }
) %>

<%= render :partial => "/tr8n/admin/common/footer" %>
